<?php

class Application_Form_Home extends Zend_Form
{

    public function init()
    {
        $this->setAttrib('id', 'frmHome')
        	 ->setAction('/admin/home')
        	 ->setMethod('post');
        	 
       	$this->addElement('hidden', 'id_home');
       	
       	$this->addElement('text', 'destacado_titulo', array(
       	'label' 	=>'Destacado títol',
       	'filters'   => array('StringTrim'),
    	'size'		=> 60,
       	'validators' => array(
                array('validator' => 'StringLength', 'options' => array(3, 30))
                )
       	));
       	
       	$this->addElement('text', 'destacado_subtitulo', array(
       	'label' 	=>'Destacat subtítol',
       	'filters'   => array('StringTrim'),
    	'size'		=> 60,
       	'validators' => array(
                array('validator' => 'StringLength', 'options' => array(3, 100))
                )
       	));
       	
       	$this->addElement('textarea', 'destacado_contenido', array(
       	'label' 	=>'Destacat contingut',
       	'filters'   => array('StringTrim'),
       	'rows' 		=> '5',
       	'cols'		=> '45',
    	));
       	
       	$this->addElement('text', 'testimonio_titulo', array(
       	'label' 	=>'Testimoni títol',
       	'filters'   => array('StringTrim'),
    	'size'		=> 60));
       	
       	$this->addElement('textarea', 'testimonio_contenido', array(
       	'label' 	=>'Testimoni contingut',
       	'filters'   => array('StringTrim'),
    	'rows' 		=> '5',
       	'cols'		=> '45'));
       	
       	$this->addElement('text', 'principal_titulo', array(
       	'label' 	=>'Principal títol',
       	'filters'   => array('StringTrim'),
    	'size'		=> 60));
       	
       	$this->addElement('text', 'principal_subtitulo', array(
       	'label' 	=>'Principal subtítol',
       	'filters'   => array('StringTrim'),
    	'size'		=> 60));
       	
       	$this->addElement('textarea', 'principal_contenido', array(
       	'label' 	=>'Principal contingut',
       	'filters'   => array('StringTrim'),
    	'rows' 		=> '5',
       	'cols'		=> '45'));
       	
       	$this->addElement('text', 'texto_promo_titulo', array(
       	'label' 	=>'Text promo títol',
       	'filters'   => array('StringTrim'),
    	'size'		=> 60));
       	
       	$this->addElement('textarea', 'texto_promo_contenido', array(
       	'label' 	=>'Texto promo contingut',
       	'filters'   => array('StringTrim'),
    	'rows' 		=> '5',
       	'cols'		=> '45'));
       	
       	$this->addElement('text', 'imagen_promo', array(
       	'label' 	=>'Imatge promo',
       	'filters'   => array('StringTrim'),
    	'size'		=> 60));
       	
       	$this->addElement('hidden', 'imagen_tipo', array(
       	'label' 	=>'Imatge tipus',
       	'filters'   => array('StringTrim'),
    	'size'		=> 40));
       	
       	$this->addElement('submit', 'submit', array(
            'ignore'   => true,
            'label'    => 'Guardar y cerrar',
        ));
    }
    
 	public function muestraErrores($array)
    {
    	$valores = array();
    	foreach ($array as $key => $value) {
    		foreach ($array[$key] as $value2) {
    			$valores[] = $key. " ". $value2;	
    		}
    	}
    	return $valores;
    }
}

